$(function() {
	$('#base').combobox('setValue', '3');
	
	doSearch();
});

function doSearch() {
	var startTime = $('#startTime').datebox('getValue');
	var endTime = $('#endTime').datebox('getValue');
	var base = $('#base').combobox('getValue');
	var carrier = $('#carrier').combobox('getValue');
	
	var newNum = [];
	var useNum = [];
	var miguNum = [];
	var rate = [];
	var pureRate = [];
	$.ajax({
		url : '/user/incr/sdkUseRateQoqData',
		data : {
			startTime : startTime,
			endTime : endTime,
			base : base,
			carrier : carrier
		},
		type : "POST",
		datatype : "json",
		async : true,
		success : function(data) {
			var yAxis = eval(data.yAxis);
			$.each(yAxis, function(index, mod) {
				newNum.push(mod.newNum);
				useNum.push(mod.useNum);
				miguNum.push(mod.miguNum);
				rate.push(mod.rate);
				pureRate.push(mod.pureRate);
			});
			showHighChart(data.xAxis, newNum, useNum, miguNum, rate, pureRate);
		}
	});
} 

function showHighChart (x, newNum, useNum, miguNum, rate, pureRate) {
	Highcharts.chart('container', {
	    title: {
	        text: 'SDK用户利用率环比'
	    },
	    xAxis: {
	        categories: x
	    },
	    series: [{
	        type: 'column',
	        name: '新增量',
	        data: newNum
	    }, {
	        type: 'column',
	        name: '使用量',
	        data: useNum
	    }, {
	        type: 'column',
	        name: '咪咕量',
	        data: miguNum
	    }, {
	        type: 'spline',
	        name: 'SDK总利用率',
	        data: rate,
	        marker: {
	            lineWidth: 2,
	            lineColor: Highcharts.getOptions().colors[3],
	            fillColor: 'white'
	        }
	    }, {
	        type: 'spline',
	        name: 'SDK利用率',
	        data: pureRate,
	        marker: {
	            lineWidth: 2,
	            lineColor: Highcharts.getOptions().colors[3],
	            fillColor: 'white'
	        }
	    }]
	});
}
